import React from 'react'
import ReactDOM from 'react-dom'

class Counter extends React.Component {
  state = {
    count: 1,
    a: 'aa'
  }
  handleClick = () => {
    console.log("+1 执行了", this)
    this.setState({
      count: this.state.count + 1
    })
  }
  render () {
    return (
      <div>
        {/*    <p>{this.state}</p>
        <button onClick={
          this.setState({
            count: this.state + 1,
          })
        }>+1</button> */}
        <h1>计数器：{this.state.count} - {this.state.a}</h1>
        <button onClick={this.handleClick}>+1</button>
      </div>
    )
  }
}
ReactDOM.render(<Counter></Counter>, document.querySelector('#root'))